package jp.inaka.mironal.android.tad.content;

import jp.inaka.mironal.android.tad.content.table.CategoryTable;
import jp.inaka.mironal.android.tad.content.table.DayTable;
import jp.inaka.mironal.android.tad.content.table.LogTable;
import jp.inaka.mironal.android.tad.content.table.TaskTable;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class ContentOpenHelper extends SQLiteOpenHelper{

    
    private static final String DB_NAME = "task_log.db";
    
    public static final String TASK_TABLE = "task";
    
    public static final String DAY_TABLE = "day";
    
    public static final String CATEGORY_TABLE = "category";
    
    public static final String LOG_TABLE = "log";
    
    private static final int VERSION = 1;
    
    public ContentOpenHelper(Context context ) {
        super(context, DB_NAME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        
        db.execSQL("CREATE TABLE " + TASK_TABLE + "("
                + TaskTable._ID + " INTEGER PRIMARY KEY, "
                + TaskTable.NAME + " TEXT, "
                + TaskTable.CATEGORY + " INTEGER "
                + ");");
        
        db.execSQL("CREATE TABLE " + CATEGORY_TABLE + "("
                + CategoryTable._ID + " INTEGER PRIMARY KEY, "
                + CategoryTable.NAME + " TEXT "
                + ");");
        
        db.execSQL("CREATE TABLE " + DAY_TABLE + "("
                + DayTable._ID + " INTEGER PRIMARY KEY, "
                + DayTable.DAY + " TEXT "
                + ");");
        
        db.execSQL("CREATE TABLE " + LOG_TABLE + "("
                + LogTable._ID + " INTEGER PRIMARY KEY, "
                + LogTable.TASK_ID + " INTEGER, "
                + LogTable.BEGIN + " TEXT, "
                + LogTable.END + " TEXT "
                + ");");
        
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        onCreate(db);
        
    }

    
    
}
